
//发送同步请求功能
function amSync(zUrl,fProcessReq,zPost){
if((!zUrl)||(zUrl.length<10)){alert("amSync 没有URL");return false}
if(!fProcessReq){alert("amSync 没有返还函数");return false;}
var	aArgs=new Array();
aArgs.zUrl=zUrl;
aArgs.mOk=fProcessReq;
aArgs.zPost=zPost;
return oAmSync.mSync(aArgs);
}
//处理返回信息功能
function okAnsSync(){return oAmSync.mResSync()};

//类定义
function fAmSync(){
this.hReq	=null;	//Ajax request handler
this.mOk	=null;	//Request ok, response method
this.zUrl	=null;	//request URL
this.Stack	=new Array();
}
//处理返回信息方法
fAmSync.prototype.mResSync=function(){
if(this.hReq.readyState!=4){return false;}//对象执行状态未完成
if(this.hReq.status==200){this.mOk(this.hReq.responseText);}//信息已经成功返回，返回处理信息
else{weMsg("您所请求的页面有异常"+this.hReq.status);}
if(this.Stack.length==0){this.zUrl=null;return true;}//同步队列，异步处理
return this.mAskSync(this.Stack.shift());
}
//ask method for inside use by mSync
fAmSync.prototype.mAskSync=function(aArgs){
this.zUrl=aArgs.zUrl;
this.mOk=aArgs.mOk;
if(window.XMLHttpRequest){		//Mozilla 浏览器
	this.hReq=new XMLHttpRequest();
	if(this.hReq.overrideMimeType){this.hReq.overrideMimeType("text/xml");}//设置 MiME 类别
}
else if(window.ActiveXObject){	// IE浏览器
 try{this.hReq=new ActiveXObject("Microsoft.XMLHTTP");
 }catch(e){
	try{this.hReq=new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){alert("浏览器不能创建XMLHttpRequest对象实例."+e);return false;}
 }
}
this.hReq.onreadystatechange=okAnsSync;
if(aArgs.zPost){
//	this.hReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	this.hReq.open("POST",aArgs.zUrl,false);
	return this.hReq.send(aArgs.zPost);
}
else{this.hReq.open("GET",aArgs.zUrl,false);return this.hReq.send(null);}
}
//interface method used by amSync
fAmSync.prototype.mSync=function(aArgs){
if(this.zUrl){this.Stack.push(aArgs);return true;}
return	this.mAskSync(aArgs);
}
//Create instance
var oAmSync=new fAmSync();
